function finduserbyid() {
	$.ajax({
		url: 'http://localhost:3000/admin/getUserById',
		method: 'GET',
		async: false,
		data: { id: sessionStorage.getItem('userid') },
		success: function (data) {
			var user = data.data;
			$('.new-address')[0].innerHTML = `
  <form id="myForm">
  <div class="box clearfix">
  <input type="text" name="id" value="${user.id}" hidden>
  <input type="text" name="username" value="${user.username}" hidden>
    <div class="left">
      <span>姓名&nbsp;：&nbsp;</span>
    </div>
    <div class="right">
      <input type="text" name="name" value="${user.name}" required="required" placeholder="请输入收货人姓名">
      <span class="Validform_checktip"></span>
    </div>
  </div>
  <div class="box clearfix">
    <div class="left">
      <span>电话&nbsp;：&nbsp;</span>
    </div>
    <div class="right">
      <input type="text" name="phone" value="${user.phone}" required="required"
        placeholder="请输入收货人电话">
      <span class="Validform_checktip"></span>
    </div>
  </div>
  <div class="box clearfix">
    <div class="left">
      <span>地址&nbsp;：&nbsp;</span>
    </div>
    <div class="right">
      <input type="text" name="address" value="${user.address}" required="required"
        placeholder="请输入收货地址">
    </div>
  </div>
  <div class="save">
    <button type="button" id="butn">保存</button>
  </div>
  </form>
  `;
		}
	});
}
finduserbyid();
$('#butn').click(function (e) {
	$.ajax({
		url: 'http://localhost:3000/admin/userEdit',
		method: 'POST',
		async: false,
		data: $('#myForm').serialize(),
		success: function (data) {
			console.log(data);
			if (data.state == 1) {
				layer.msg(
					'修改成功',
					{
						icon: 1,
						time: 800
					},
					function () {
						location.href = './index.html';
					}
				);
			} else {
				layer.msg(data.msg, {
					icon: 2,
					time: 800
				});
			}
		}
	});
});
